const path = require('path')
const vuxLoader = require('vux-loader')
const webpack = require('webpack')
const {
	resolve
} = require('path')
 
const env = require('./env')

module.exports = {
	render: { resourceHints: false },
	env: {
		mallApi: env[process.env.MODE].ENV_MALL_API,
		workUrl: env[process.env.MODE].ENV_WORK_URL
	},	
	head: {
		title: '升学在线',
		meta: [{
				charset: 'utf-8'
			},
			{
				name: "referrer",
				content: "no-referrer"
			},
			{
				name: 'format-detection',
				content: 'telephone=yes'
			},
			{
				name: 'viewport',
				content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no'
			},
			{
				hid: 'description',
				name: 'description',
				content: '{{escape description }}'
			}
		],
		link: [{
			rel: 'icon',
			type: 'image/x-icon',
			href: '/favicon.ico'
		}],
		script: [{
			innerHTML: "document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + `px`;",
			type: 'text/javascript'
		}]
	},
	router: {
		base: '/h5-js/',
		mode: 'hash',		
    prefetchLinks: false
	},
	loading: {
		color: '#3B8070'
	},
	plugins: [{
			src: '~plugins/axios',
			ssr: false
		},
		{
			src: '~plugins/axios1',
			ssr: false
		},
		{
			src: '~plugins/axios2',
			ssr: false
		},
		{
			src: '~plugins/axios3',
			ssr: false
		},
		{
			src: '~/plugins/global',
			ssr: false
		},
		{
			src: '~/plugins/vux-plugins',
			ssr: false
		},
		{
			src: '~/plugins/filter',
			ssr: false
		}
// 		{
// 			src:'~/plugins/echarts',
// 			ssr: false
// 		}
	],
	build: {
		uglify: {
			uglifyOptions: {
				mangle: {
					safari10: true
				}
			}
		},
		extend(config, {
			isDev,
			isClient
		}) {
			if (isDev && isClient) {
				config.module.rules.push({
					enforce: 'pre',
					test: /\.(js|vue)$/,
					loader: 'eslint-loader',
					exclude: /(node_modules)/
				})
			}
			const configs = vuxLoader.merge(config, {
				options: {
					ssr: true
				},
				plugins: ['vux-ui', {
					name: 'less-theme',
					path: path.join(__dirname, './styles/theme.less')
				}]
			})
			return configs
		},
	},
	modules: [
		'@nuxtjs/axios',
		'@nuxtjs/proxy'
	],
	/*
	 ** proxy
	 */
	proxy: {
		// 正式的
		'/shengxueApi': {
			// target:'http://47.111.165.236:8080',
			target: 'https://app-test.shengxue985.sx985.com',
			changeOrigin: true,
			pathRewrite: {
				'^/shengxueApi': 'shengxueApi'
			}
		},
		'/academy': {
			target: 'https://app-test.shengxue985.sx985.com',
			changeOrigin: true,
			pathRewrite: {
				'^/academy': 'academy'
			}
		},

		'/shengxue': {

			// target: 'https://app.shengxue985.com',
			target: 'https://app-test.shengxue985.sx985.com',
			changeOrigin: true,
			pathRewrite: {
				'^/shengxue': 'shengxue'
			}
		},
		'/teachapi': {
		
			// target: 'https://app.shengxue985.com',
			target: 'http://api-mall.test',
			changeOrigin: true,
			pathRewrite: {
				'^/teachapi': ''
			}
		}
	

	},
	css: [
		'assets/css/main.css'
	],
}
